{% extends "base.html" %}
{% load endless %}
{% block breadcrumb %}
 	{{ block.super }} <a href="{{site.name}}/cart/list">Changuito</a>
{% endblock %}
{% block content %}
	{% if not orderItems %}
		<h2 id="msg_result">No hay articulos cargados en su changuito</h2>
	{% else %}
	<h3 style="color: #F93200;">ATENCION:Los precios no incluyen ENVIO, el mismo debe ser acordado con el vendedor.</h3>
	{% load humanize %}
    {% paginate 5 orderItems %}
    <strong>Pagina</strong>
	{% get_pages %}
	{{ pages }}
    {% for orderItem in orderItems %}
	<table id="cart_table" name="{{orderItem.cart.code}}" class="item-table">   
		<tr>
		  <th></th>
		  <th>Articulo</th>
		  <th>Cantidad</th>
		  <th>Precio unitario</th>
		  <th>SubTotal</th>
		  <th></th>
		</tr>  
		<tbody>
		    <tr>
				<input type="hidden" id="order_item-{{orderItem.cart.code}}" value="{{orderItem.id}}"/> 
		    	<td><a href="{{site.name}}/articulo_{{ orderItem.product.slug }}__categoria_{{ orderItem.product.category.slug }}__catalogo_{{ orderItem.product.category.catalog.slug }}"><img class="img-table" src="{{ orderItem.product.photo.image.url }}"
				    			 alt="{{ orderItem.product.photo.title }}" />
				    	</a>
				</td>
		    	<td>
		    	    <p>{{ orderItem.product.description }}</p>
		    	</td>
		    	<td>
		    		<input type="text" 
					  		 id="quantity-{{orderItem.id}}" 
					  		 size="3" 
					  		 length="3" 
					  		 value="{{ orderItem.quantity }}"
					  		 title="El Máximo de unidades de compra fue establecido en 99."  
					  onkeydown="return ( event.ctrlKey || event.altKey 
                    || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) 
                    || (95<event.keyCode && event.keyCode<106)
                    || (event.keyCode==8) || (event.keyCode==9) 
                    || (event.keyCode>34 && event.keyCode<40) 
                    || (event.keyCode==46) )"/>
		    	</td>
		    	<td>
		    	    <p >$ ARG {{ orderItem.unitPrice }}  </p>
		    	</td>
		    	<td>
		    	    <p > Subttal {{ orderItem.subTotalPrice }}  </p>
		    	</td>
		    	<td>
		    		<p>
		    			<input id="updateOrderItem-{{ orderItem.product.code }}" 
					       title="Haga click para actualizar la cantidad ingresada."
						   class="button-update-quantity" 
						   type="button" 
						   onclick="updateOrderItem({{orderItem.product.code}},{{orderItem.id}});">
						<input id="removeItem-{{ orderItem.product.code }}" 
					       title="Haga click para quitar del changuito."
						   class="button-removeItem" 
						   type="button" 
						   onclick="window.top.location.href='{{site.name}}/cart/{{ orderItem.cart.code }}/remove/{{ orderItem.product.code }}'">
		    	    </p>
		    	</td>
		    </tr>
		</tbody>
	</table>
    {% endfor %}
	<strong>Pagina</strong>
    {% get_pages %}
	{{ pages }}
	<div class="order-still-shop">
		<label for="order">Seguir agregando articulos</label>
			<input id="order" 
		       title="confirmar y finalizar la carga del changuito"
			   class="button-still-shop" 
			   type="button" 
			   onclick="window.top.location.href='{{site.name}}'">
	</div>
	<div class="order-sumary-info">
		<h2>Total del pedido: $ Arg {{ sumSubTotal }}</h2>
		<label for="order">Debes hacer click Aqui para iniciar el pedido >>>>>>></label>
			<input id="order" 
		       title="confirmar y finalizar la carga del changuito"
			   class="button-order" 
			   type="button" 
			   onclick="order();">
	</div>
	{% endif %}
	{% if errors %}
		   <p>{{ errors }}</p>
	{% endif %}
	<script>
		function updateOrderItem(code,orderItemId){
	 	   window.top.location.href="{{site.name}}/cart/add/" + code + "/" + document.getElementById("quantity-"+orderItemId).value;
		 }
		 function order(){
		 	   window.top.location.href = "{{site.name}}/addOrder/{{ cart.code }}";
		 }
	</script>
	
{% endblock %}
